Morphology control of carbon-based nanomaterials (nanocarbons) is critical to practical applications because their physical and chemical properties are highly shape-dependent. The discovery of novel shaped nanocarbons stimulates new development in carbon science and technology. Based on direct reaction of CO2 with Mg metal, we achieved controlled synthesis of several different types of nanocarbons including mesoporous graphene, carbon nanotubes, and hollow carbon nanoboxes. The last one, to our knowledge, has not been previously reported to this date. The method described here allows effective control of the shape and dimensions of nanocarbons through manipulation of reaction temperature. The formation mechanism of nanocarbons is proposed. As a proof of concept, the synthesized nanocarbons are used for electrodes in symmetrical supercapacitors, which exhibit high capacitance and good cycling stability. The reported protocols are instructive to production of nanocarbons with controlled shape and dimensions which are much desirable for many practical applications.